import java.util.LinkedList;

/**
 * @author leiwenkang <leiwenkang@kuaishou.com>
 * Created on 2023-07-31
 */
public class Study {
    /**
     * 1, 2, 2, 4, 5, 5
     * @param args
     */
    public static void main(String[] args) {
        int[] array = {1, 2, 2, 4, 5, 5};
        String str = ":2001:0db8:85a3:0:0:8A2E:0370:7334:";
        String[] strArray1 = str.split(":", -1);
        String[] strArray2 = str.split(":");
        LinkedList<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        System.out.println(list);

        System.out.println(strArray1.length);
        System.out.println(strArray1[strArray1.length - 1]);
        System.out.println(strArray2.length);
        System.out.println(strArray2[strArray2.length - 1]);
        System.out.println(findAppearOnceNumber(array)[0]);
        System.out.println(findAppearOnceNumber(array)[1]);
    }

    public static int[] findAppearOnceNumber(int[] array) {
        if (array == null || array.length == 0) {
            return null;
        }

        int temp = 0;
        for (int i = 0;i < array.length; i++) {
            temp ^= array[i];
        }

        //找到二进制为1的位置
        int index = 1;
        while ((temp & index) != 1) {
            index <<= 1;
        }

        //将数组按照index位置二进制是否为1一分为二
        int num1 = 0;
        int num2 = 0;
        for (int i = 0;i < array.length; i++) {
            if ((array[i] & index) == 1) {
                num1 ^= array[i];
            } else {
                num2 ^= array[i];
            }
        }

        return new int[] {num1, num2};
    }
}
